package com.github.pig.nideshop.controller.user;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.github.pig.common.util.ZyResult;
import com.github.pig.nideshop.entity.NideshopComment;
import com.github.pig.nideshop.model.vo.CommentVo;
import com.github.pig.nideshop.service.INideshopCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author J神
 * @since 2018-06-11
 */
@RestController
@RequestMapping("/comments")
public class NideshopCommentController {
    @Autowired
    private INideshopCommentService nideshopCommentService;

    /**
     * 评论列表
     * valueId 商品id
     * @param comment
     * @param page
     * @return
     */
    @GetMapping
    public ZyResult comments(NideshopComment comment, Page page){
        List<String> des=new ArrayList<>();
        des.add("addTime");
        page.setDescs(des);
        Page<CommentVo> pages=nideshopCommentService.selectVoPage(page,comment);
        return ZyResult.ok(pages);
    }

    /**
     * 新增评论
     * @param commentVo
     * @return
     */
    @PostMapping
    public ZyResult comment(@RequestBody CommentVo commentVo){
        return ZyResult.ok();
    }
}

